//二次封装axios
import axios from 'axios'
import Nprogress from 'nprogress'
import 'nprogress/nprogress.css'

//配置基础通用的路径和超时处理
const service = axios.create({
    baseURL:'/api',
    timeout:20000,
})

//请求拦截器
service.interceptors.request.use((config)=>{
    Nprogress.start()
    return config
}),
service.interceptors.response.use(
    resopnse=>{
        Nprogress.done()
        return resopnse.data     
},
    error=>{
        Nprogress.done()
        // throw error
        return Promise.reject(error)
    }
)
export default service

